package com.wmh.baseservice.common.config;

import com.alibaba.fastjson2.JSONWriter;
import com.alibaba.fastjson2.writer.ObjectWriter;

import java.lang.reflect.Type;

/**
 * @author 谢骏
 * @date 2023/3/20 10:08
 * Long 转 string 序列化字段
 **/
public class LongToStringSerializer implements ObjectWriter<Long> {

    @Override
    public void write(JSONWriter jsonWriter, Object o, Object o1, Type type, long l) {

        if (o == null) {
            jsonWriter.writeNull();
        } else {
            String strVal = o.toString();
            jsonWriter.writeString(strVal);
        }
    }
}